package com.lezhu.plcsdklibrary.manager;

import com.lezhu.plcsdklibrary.callback.HumanApproachListener;

import java.util.ArrayList;

/**
 * 描述人体红外感应回调管理
 * 作者: 钮家齐
 * 时间: 2020/6/1 9:11
 */
public class InfraredSensorCallBackManager {

    private static InfraredSensorCallBackManager sensorCallBackManager;
    private static ArrayList<HumanApproachListener> list;

    public static InfraredSensorCallBackManager getInstance(){
        if(sensorCallBackManager==null){
            synchronized (InfraredSensorCallBackManager.class){
                if(sensorCallBackManager==null){
                    sensorCallBackManager = new InfraredSensorCallBackManager();
                    list = new ArrayList<>();
                }
            }
        }
        return sensorCallBackManager;
    }


    public void addhumanApproachListener(HumanApproachListener statusInterface){
        list.add(statusInterface);
    }


    public void removehumanApproachListener(HumanApproachListener statusInterface){
        if(list.contains(statusInterface)){
            list.remove(statusInterface);
        }
    }

    public void come(){
        for(HumanApproachListener sensorInterface: list){
            sensorInterface.come();
        }
    }

    public void go(){
        for(HumanApproachListener sensorInterface: list){
            sensorInterface.go();
        }
    }
}
